<!DOCTYPE html>
<html>
<head>
<title>结账小票打印</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/static/css/my.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css">
    <script src="https://ajax.aspnetcdn.com/ajax/jquery/jquery-1.9.0.min.js"></script>    
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="/static/layer/layer/layer.js"></script>
<style>

</style>
</head>
<body >
<!--startprint-->
<div class="container-fluid" style="max-width: 300px;">

    <div style="font-size:1.5rem;text-align: left;">{$sys.sys_name}&nbsp;结账单</div>
    <div class="text-primary" style="font-size: 1rem;">
        <div>餐桌：{$order.table_id_name}</div>
        <div>单号：{$order.order_no}</div>
        <div>下单人：{$order.creater_name}</div>
        <div>时间：{$order.create_time}</div>
    </div>

    <table class="" style="width: initial;min-width: 100%;">
        <thead style="border-top:1px solid #ccc;">
            <th>Item</th>
            <th>Price</th>
            <th>Count</th>
            <th>Total</th>
        </thead>
        <tbody style="border-top:1px solid #ccc;">
            {foreach $list as $k=>$kv}
            <tr>
                <td>{$kv['name']}</td>
                <td>{$kv['price']}</td>
                <td>x{$kv['num']}</td>
                <td>{$kv['total']}</td>
            </tr>
            {/foreach}
            <tr style="border-top:1px solid #ccc;font-weight: bold;">
                <td>Total</td>
                <td>{$num}</td>
                <td></td>
                <td>{$sum}</td>
            </tr>
        </tbody>    
    </table>
    <div style="border-top:1px solid #ccc;">
        <div style="font-size:1.2rem;font-weight: bold;">应收：『{$sum}』 </div>
        <div style="font-size:1.2rem;">
            实收：『{$order['price2']}』 
            {if $order['discount']<1}
                折扣:{$order['discount']*100}%
            {/if}
        </div>
        <div>收银员：{$order['checkout_id_name']}</div>
        <div>支付方式：{$order['payment_name']}</div>
        <div>时间：{$order['checkout_time']}</div>
    </div>

</div>
<!--endprint-->
<p></p>
<div class="text-center">
    <button class="btn btn-sm btn-primary" type="button" onclick="printpage();">
        <span class="bi-printer"></span> Print
    </button>
</div>

<div style="height:50px;text-align: center;color:#999"></div>
</body>

<script type="text/javascript">

  $(document).ready(function(){



  })

    function printpage(){
      let oldStr = window.document.body.innerHTML; // 获取body的内容
      let start = "<!--startprint-->"; // 开始打印标识, 17个字符
      let end = "<!--endprint-->"; // 结束打印标识
      let newStr = oldStr.substr(oldStr.indexOf(start) + 17); // 截取开始打印标识之后的内容
      newStr = newStr.substring(0, newStr.indexOf(end)); // 截取开始打印标识和结束打印标识之间的内容
      window.document.body.innerHTML = newStr; // 把需要打印的指定内容赋给body
      window.print(); // 调用浏览器的打印功能打印指定区域
      window.document.body.innerHTML = oldStr; // body替换为原来的内容
    }
</script>


</body>
</html>
